﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BranchOfSansar.Sansar.Transfer;
namespace BranchOfSansar.Register.Trans
{
    public partial class frmCreateDebit : Form
    {
        public frmCreateDebit()
        {
            InitializeComponent();
        }

        private void frmCreateDebit_Load(object sender, EventArgs e)
        {
            dtDebit.DateTime = Globals.GetDate();
            dtTxnDate.DateTime = Globals.GetDate();
        }

        private void cmdExit_Click(object sender, EventArgs e)
        {
            DialogResult = System.Windows.Forms.DialogResult.Cancel;
        }

        private void cmdSave_Click(object sender, EventArgs e)
        {
            using (TransferClient obj = new TransferClient(Globals.Token))
            {
                Result r=obj.CalculateDebit(dtDebit.DateTime.Year.ToString() + dtDebit.DateTime.Month.ToString("00"),dtTxnDate.DateTime, Globals.UserId,1,"127.0.0.1");
                if (r.Code != 0)
                {
                    Globals.Err(r.Message);
                    return;
                }
                else
                {
                    Globals.Info(r.Message);
                    cmdSave.Enabled = false;
                    return;
                }                
                //DialogResult = System.Windows.Forms.DialogResult.OK;
            }
        }
    }
}
